package com.iris.live.services.common.reconsitution;
import com.iris.live.services.data.repositories.StockForecastRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * Created by yitianle on 2017/9/1.
 * 根据title切入公式
 */
@Component()
public class StockForecastUtils {

    private  final static String ORDER_FORM_ON_TYE_WAY_STOCK = "在途库存";
    private  final static String ORDER_FORM_LOCAL_STOCK = "在店库存";
    private  final static String ORDER_FORM_AVG_STOCK_DAY = "平均库存天数";
    private  final static String ORDER_FORM_SALE_TARGET = "销售目标";
    private  final static String ORDER_FORM_CLUE_STOCK = "存量线索";
    private  final static String ORDER_FORM_CLUE_ADD = "增量线索";
    private  final static String ORDER_FORM_CLUE_STORE_RATE = "线索进店率";
    private  final static String ORDER_FORM_CLUE_STORE = "进店线索数";
    private  final static String ORDER_FORM_CLUE_STORE_ORDER_RATE = "进店线索订单率";
    private  final static String ORDER_FORM_ORDER_ADD = "新增订单";
    private  final static String ORDER_FORM_STOCK_ORDER = "存量订单";
    private  final static String ORDER_FORM_ORDER_LEAVE_CAR_RATE = "订单交车率";
    private  final static String ORDER_FORM_SALE_FORECAST = "销售预计";
    private  final static String ORDER_FORM_SALE_GAP = "销售缺口";
    private  final static String ORDER_FORM_STOCK_GAP = "库存缺口";
    private  final static String ORDER_FORM_NO_STOCK = "未分配资源";
    private  final static String ORDER_FORM_PURCHASE_GAP = "采购缺口";

    private static StockForecastRepository stockForecastRepository;



    /**
     * 订单表单获取值
     * @param title
     * @return
     */
    public static String orderFormValue(String title,String brand,String carSeries,String carModel,String permit){
        String  value ="0.0";
        if(StockForecastUtils.ORDER_FORM_ON_TYE_WAY_STOCK.equals(title)){
            value = String.valueOf(stockForecastRepository.getStockOnTheWay(brand,carSeries,carModel,1,permit));
        }else if (StockForecastUtils.ORDER_FORM_LOCAL_STOCK.equals(title)){
            value = String.valueOf(stockForecastRepository.getStockOnTheWay(brand,carSeries,carModel,2,permit));
        }else if(StockForecastUtils.ORDER_FORM_AVG_STOCK_DAY.equals(title)){
            value = String.valueOf(stockForecastRepository.getAvgStockTurnoverDays(brand,carSeries,carModel,permit));
        }else if(StockForecastUtils.ORDER_FORM_SALE_TARGET.equals(title)){
            value = String.valueOf(stockForecastRepository.getSaleTarget(brand,carSeries,carModel,permit));
        }else if(StockForecastUtils.ORDER_FORM_CLUE_STOCK.equals(title)){
            value = String.valueOf(stockForecastRepository.getClueStockNum(brand,carSeries,carModel,permit));
        }else if(StockForecastUtils.ORDER_FORM_CLUE_ADD.equals(title)){
            value = String.valueOf(stockForecastRepository.getClueAddNum(brand,carSeries,carModel,permit));
        }else if(StockForecastUtils.ORDER_FORM_CLUE_STORE_RATE.equals(title)){
            value = String.valueOf(stockForecastRepository.getClueStoreRate(brand,carSeries,carModel,permit));
        }else if(StockForecastUtils.ORDER_FORM_CLUE_STORE.equals(title)){
            value = String.valueOf(stockForecastRepository.getClueStoreNum());
        }else if(StockForecastUtils.ORDER_FORM_CLUE_STORE_ORDER_RATE.equals(title)){
            value = String.valueOf(stockForecastRepository.getClueStoreOrderNum(brand,carSeries,carModel,permit));
        }else if(StockForecastUtils.ORDER_FORM_STOCK_ORDER.equals(title)){
            value = String.valueOf(stockForecastRepository.getStockOrderNum(brand,carSeries,carModel,permit));
        }else if(StockForecastUtils.ORDER_FORM_ORDER_LEAVE_CAR_RATE.equals(title)){
            value = String.valueOf(stockForecastRepository.getOrderLeaveCarNum(brand,carSeries,carModel,permit));
        }else if(StockForecastUtils.ORDER_FORM_SALE_FORECAST.equals(title)){
            value = String.valueOf(stockForecastRepository.saleEstimate());
        }else if(StockForecastUtils.ORDER_FORM_SALE_GAP.equals(title)){
            value = String.valueOf(stockForecastRepository.saleGap());
        }else if(StockForecastUtils.ORDER_FORM_STOCK_GAP.equals(title)){
            value = String.valueOf(stockForecastRepository.stockGap());
        }else if(StockForecastUtils.ORDER_FORM_NO_STOCK.equals(title)){
            value = String.valueOf(stockForecastRepository.undistributedSource(brand,carSeries,carModel,permit));
        }else if(StockForecastUtils.ORDER_FORM_PURCHASE_GAP.equals(title)){
            value = String.valueOf(stockForecastRepository.purchaseGap());
        }else if(StockForecastUtils.ORDER_FORM_ORDER_ADD.equals(title)){
            value = String.valueOf(stockForecastRepository.getAddOrderNum());
        }
        return value;
    }

    @Autowired
    public void setStockForecastRepository(StockForecastRepository stockForecastRepository) {
        StockForecastUtils.stockForecastRepository = stockForecastRepository;
    }

}
